using UnityEngine;
using MinesweeperPlus.Scripts.Abstractions;
using MinesweeperPlus.Scripts.Abstractions.Interfaces;
using MinesweeperPlus.Scripts.Objects;
using MinesweeperPlus.Scripts.Utils;

namespace MinesweeperPlus.Scripts.Configs
{
    [CreateAssetMenu(
        fileName = nameof(LevelConfig), 
        menuName = Constants.SO_CONFIG_MENU_NAME + nameof(LevelConfig))]
    public class LevelConfig : ConfigBase
    {
        #region Properties
        [field: SerializeField] public string Name { get; private set; }
        [field: Space]
        [field: SerializeField] public int Width { get; private set; }
        [field: SerializeField] public int Height { get; private set; }
        [field: SerializeField] public int NumberOfMines { get; private set; }
        [field: Space]
        [field: SerializeField] public int[] TimeValuesForRemoveStar { get; private set; }
        #endregion

        #region Unity Methods
        private void OnValidate()
        {
            for (int i = 1; i < TimeValuesForRemoveStar.Length; i++)
            {
                var firstTime = TimeValuesForRemoveStar[i - 1];
                var secondTime = TimeValuesForRemoveStar[i];
                if (firstTime >= secondTime)
                    throw new System.Exception($"Element [{i - 1}] must be less than Element [{i}]");
            }
        }
        #endregion
    }
}
